package com.example.jinggai;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    EditText name,pass;
    Button  denglu;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        denglu = findViewById(R.id.btn_login);
        name = findViewById(R.id.et_username);
        pass = findViewById(R.id.et_password);

        denglu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(name.getEditableText().toString().equals("admin") && pass.getEditableText().toString().equals("123")){
                    Intent intent = new  Intent(MainActivity.this,FuncActivity.class);
                    SPUtils.put(MainActivity.this,"user","admin");
                    startActivity(intent);
                    finish();

                }else if(name.getEditableText().toString().equals("b") && pass.getEditableText().toString().equals("123")){
                    Intent intent = new  Intent(MainActivity.this,FuncActivity.class);
                    SPUtils.put(MainActivity.this,"user","b");
                    startActivity(intent);
                    finish();

                }


                else {
                    Toast.makeText(MainActivity.this,"账号密码错误",Toast.LENGTH_SHORT).show();

                }



            }
        });
    }
}